package com.muyu.system.controller;


import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.common.security.annotation.RequiresPermissions;
import com.muyu.system.domain.DanmoShoppingOrderCartDetails;
import com.muyu.system.service.IDanmoShoppingOrderCartDetailsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 购物车订单Controller
 * 
 * @author kunzong
 * @date 2024-12-13
 */
@RestController
@RequestMapping("/DanmoShoppingOrderCartDetails")
public class DanmoShoppingOrderCartDetailsController extends BaseController
{
    @Autowired
    private IDanmoShoppingOrderCartDetailsService danmoShoppingOrderCartDetailsService;

    /**
     * 查询购物车订单列表
     */
    @RequiresPermissions("system:DanmoShoppingOrderCartDetails:list")
    @GetMapping("/list")
    public Result list(DanmoShoppingOrderCartDetails danmoShoppingOrderCartDetails)
    {
        startPage();
        List<DanmoShoppingOrderCartDetails> list = danmoShoppingOrderCartDetailsService.selectDanmoShoppingOrderCartDetailsList(danmoShoppingOrderCartDetails);
        return Result.success(list);
    }

    /**
     * 导出购物车订单列表
     */
    @RequiresPermissions("system:DanmoShoppingOrderCartDetails:export")
    @Log(title = "购物车订单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DanmoShoppingOrderCartDetails danmoShoppingOrderCartDetails)
    {
        List<DanmoShoppingOrderCartDetails> list = danmoShoppingOrderCartDetailsService.selectDanmoShoppingOrderCartDetailsList(danmoShoppingOrderCartDetails);
        ExcelUtil<DanmoShoppingOrderCartDetails> util = new ExcelUtil<DanmoShoppingOrderCartDetails>(DanmoShoppingOrderCartDetails.class);
        util.exportExcel(response, list, "购物车订单数据");
    }

    /**
     * 获取购物车订单详细信息
     */
    @RequiresPermissions("system:DanmoShoppingOrderCartDetails:query")
    @GetMapping(value = "/{id}")
    public Result getInfo(@PathVariable("id") Long id)
    {
        return Result.success(danmoShoppingOrderCartDetailsService.selectDanmoShoppingOrderCartDetailsById(id));
    }

    /**
     * 新增购物车订单
     */
    @RequiresPermissions("system:DanmoShoppingOrderCartDetails:add")
    @Log(title = "购物车订单", businessType = BusinessType.INSERT)
    @PostMapping
    public Result add(@RequestBody DanmoShoppingOrderCartDetails danmoShoppingOrderCartDetails)
    {
        return Result.success(danmoShoppingOrderCartDetailsService.insertDanmoShoppingOrderCartDetails(danmoShoppingOrderCartDetails));
    }

    /**
     * 修改购物车订单
     */
    @RequiresPermissions("system:DanmoShoppingOrderCartDetails:edit")
    @Log(title = "购物车订单", businessType = BusinessType.UPDATE)
    @PutMapping
    public Result edit(@RequestBody DanmoShoppingOrderCartDetails danmoShoppingOrderCartDetails)
    {
        return Result.success(danmoShoppingOrderCartDetailsService.updateDanmoShoppingOrderCartDetails(danmoShoppingOrderCartDetails));
    }

    /**
     * 删除购物车订单
     */
    @RequiresPermissions("system:DanmoShoppingOrderCartDetails:remove")
    @Log(title = "购物车订单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public Result remove(@PathVariable Long[] ids)
    {
        return Result.success(danmoShoppingOrderCartDetailsService.deleteDanmoShoppingOrderCartDetailsByIds(ids));
    }
}
